﻿using SmallJob.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmallShop.Services.Code
{
    public class MongoConvert
    {
        public static MUser ConvertUser(User user)
        {
            MUser mu = new MUser();
            mu.ID = user.ID;
            mu.Name = user.ProperName;
            mu.UserName = user.UserName;
            mu.Avatar = user.Avatar;
            return mu;
        }
        public static MOrder ConvertOrder(Order order, Provide provide, Request request)
        {
            MOrder mo = new MOrder();
            mo.OrderID = order.ID;
            mo.OrderType = order.Type;
            mo.SellerID = order.SellerID;
            mo.BuyerID = order.BuyerID;
            mo.IsNoDisplay = false;
            if (provide != null) mo.Provide = ConvertProvide(provide);
            if (request != null) mo.Request = ConvertRequest(request);
            return mo;
        }
        public static MProvide ConvertProvide(Provide provide)
        {
            MProvide mp = new MProvide();
            mp.ID = provide.ID;
            mp.Title = provide.Title;
            mp.HostID = provide.UserID;
            return mp;
        }
        public static MRequest ConvertRequest(Request provide)
        {
            MRequest mp = new MRequest();
            mp.ID = provide.ID;
            mp.Title = provide.Title;
            mp.HostID = provide.AssignedUserID;
            return mp;
        }
    }
}
